#include <iostream>
#include <string.h>
#include <cmath>
using std::cout;
using std::endl;

class Point{
public:
    Point()
    :_x(0)
    ,_y(0)
    {}
    Point(int x,int y)
    :_x(x)
    ,_y(y)
    {}
    friend class Line;
private:
    float _x;
    float _y;
};

class Line{
public:
    Line()
    :_p1(0,0),_p2(0,0)
    {}

    Line(double x1,double y1,double x2,double y2)
    :_p1(x1,y1)
    ,_p2(x2,y2)
    {}
    
    double len(){
        int x_gap = _p1._x - _p2._x;
        int y_gap = _p2._y - _p2._y;
        return sqrt(pow(x_gap,2) + pow(y_gap,2));
    }

private:
    Point _p1;
    Point _p2;
};

class Color{
public:
    Color()
    :_color(nullptr)
    {
    }
    Color(const char* color)
    :_color(new char[strlen(color)+1]())
    {
        strcpy(_color,color);
    }

    ~Color(){
        if(_color){
            delete [] _color;
            _color = nullptr;
        }
    }
    void print_color(){
        cout <<"color:" <<_color << endl;
    }

private:
    char * _color;
};

class Triangle:public Line,public Color
{
public:
    Triangle(const char * color,int h,
             double x1,double y1,
             double x2,double y2)
    :Color(color)
    ,Line(x1,y1,x2,y2)
    ,_h(h)
    {
    }

    double getArea(){
        return len() * _h / 2; 
    }
    double getPerimater(){
        double third = sqrt(pow(_h,2)+pow(len(),2));
        return len() + _h + third;
    }
    void print_tri(){
        print_color();
        cout <<"perimater:" <<getPerimater() << endl;
        cout <<"area:" <<getArea() << endl;
    } 

private:
    double _h;

};

void test(){
    Triangle t("red",1,1,2,2,10);
    t.print_tri();
}

int main()
{
    test ();
    return 0;
}

